﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace WorkStation.Frameworks.EasyBus.Serializable
{
    /// <summary>
    /// 默认消息序列化（Newtonsoft.Json实现）
    /// </summary>
    public class DefaultMessageSerializable : IMessageSerializable
    {
        #region IMessageSerializable 成员

        public string ObjectToJson(object obj)
        {
            return JsonConvert.SerializeObject(obj);
        }

        public object JsonToObject(string json, Type targetType)
        {
            return JsonConvert.DeserializeObject(json, targetType);
        }

        #endregion
    }
}
